package com.ncmx.lmax.engine.essentials;

import java.io.Serializable;
import java.util.UUID;

/**
 * The Class OrderEntry.
 * 
 * @author neerajy
 */
public class OrderEntry implements Serializable {

	/** The order id. */
	private String orderId;

	/** The side. */
	private OrderSide side;

	/** The broker. */
	private String broker;

	/** The quantity. */
	private int quantity;

	/** The order type. */
	private OrderType orderType;

	/**
	 * Instantiates a new order entry.
	 * 
	 * @param side
	 *            the side
	 * @param broker
	 *            the broker
	 * @param quantity
	 *            the quantity
	 * @param orderType
	 *            the order type
	 */
	public OrderEntry(String orderId,OrderSide side, String broker, int quantity,
			OrderType orderType) {
		this.orderId =orderId; //UUID.randomUUID().toString();
		this.side = side;
		this.broker = broker;
		this.quantity = quantity;
		this.orderType = orderType;
	}

	public OrderEntry(Builder builder) {
		this.orderId = builder.orderId;//UUID.randomUUID().toString();
		this.side = builder.side;
		this.broker = builder.broker;
		this.quantity = builder.quantity;
		this.orderType = builder.orderType;
	}

	/**
	 * Gets the order id.
	 * 
	 * @return the order id
	 */
	public String getOrderId() {
		return orderId;
	}

	/**
	 * Gets the side.
	 * 
	 * @return the side
	 */
	public OrderSide getSide() {
		return side;
	}

	/**
	 * Gets the broker.
	 * 
	 * @return the broker
	 */
	public String getBroker() {
		return broker;
	}

	/**
	 * Gets the quantity.
	 * 
	 * @return the quantity
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * Gets the order type.
	 * 
	 * @return the order type
	 */
	public OrderType getOrderType() {
		return orderType;
	}

	@Override
	public String toString() {
		return "OrderEntry [orderId=" + orderId + ", side=" + side
				+ ", broker=" + broker + ", quantity=" + quantity
				+ ", orderType=" + orderType + "]";
	}

	public static class Builder {

		/** The order id. */
		private String orderId;

		/** The side. */
		private OrderSide side;

		/** The broker. */
		private String broker;

		/** The quantity. */
		private int quantity;

		/** The order type. */
		private OrderType orderType;

		public Builder(String orderId,OrderSide side, String broker, int quantity,
				OrderType orderType) {
			this.orderId=orderId;
			this.side = side;
			this.broker = broker;
			this.quantity = quantity;
			this.orderType = orderType;
		}

		public OrderEntry build() {
			return new OrderEntry(this);
		}
	}
}
